//
//  SLCustomerTestimonialsHeadComponent.m
//  SulitLoanDemo
//
//  Created by 虞嘉伟 on 2025/2/19.
//  
  

#import "SLCustomerTestimonialsHeadComponent.h"
#import <YYKit.h>
#import <Masonry.h>


@implementation SLCustomerTestimonialsHeadComponent

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.circle];
        [self addSubview:self.titleLabel];
        [self addSubview:self.moreButton];
        [self.circle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self);
            make.centerY.equalTo(self);
            make.width.height.mas_equalTo(15);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.circle.mas_right).offset(5);
            make.centerY.equalTo(self.circle);
        }];
        [self.moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLabel.mas_right).offset(5);
            make.right.equalTo(self);
            make.centerY.equalTo(self.circle);
            make.width.height.mas_equalTo(22);
        }];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.circle.layer.cornerRadius = CGRectGetHeight(_circle.bounds)*0.5;
}

- (UIView *)circle {
    if (!_circle) {
        _circle = [UIView new];
        _circle.layer.borderColor = UIColorHex(#1B1B1B).CGColor;
        _circle.layer.borderWidth = 1.5;
    }
    return _circle;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.textColor = UIColorHex(#1B1B1B);
        _titleLabel.font = aspectDefaultFont(16);
        _titleLabel.text = @"Customer Testimonials";
    }
    return _titleLabel;
}

- (UIButton *)moreButton {
    if (!_moreButton) {
        _moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_moreButton setImage:[UIImage imageNamed:@"btn_more_black"] forState:UIControlStateNormal];
    }
    return _moreButton;
}
@end
